<%@ page language="java" contentType="text/html; charset=UTF8"
    pageEncoding="UTF8"
    import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF8">
<title>Insert title here</title>
</head>
<body>
    <%
        request.setCharacterEncoding("utf-8");
        String id =  request.getParameter("id");
		String book_index = request.getParameter("book_index");
		String title = request.getParameter("title");
		String author = request.getParameter("author");
		String publisher = request.getParameter("publisher");
		String publish_time = request.getParameter("publish_time");
		String category = request.getParameter("category");
		String price = request.getParameter("price");
        
        Class.forName("com.mysql.jdbc.Driver");
		
		String url = "jdbc:mysql://localhost:3306/test";
		String db_username = "root";
		String db_password = "";
		Connection conn = DriverManager.getConnection(url, db_username, db_password);
		
		Statement stmt = conn.createStatement();
        String sql = "update book set ";
        sql += "book_index = '" + book_index + "', ";
        sql += "title = '" + title + "', ";
        sql += "author = '" + author + "', ";
        sql += "publisher = '" + publisher + "', ";
        sql += "publish_time = DATE('" + publish_time + "'), ";
        sql += "category = " + category + ", ";
        sql += "price = " + price + " ";
        sql += "where id = " + id;
		out.println(sql);
		out.println("<br/>");
		
		int row = stmt.executeUpdate(sql);
		
		stmt.close();
		conn.close();
		
		response.sendRedirect("BookSystem.jsp");
    %>
</body>
</html>